<%@ page contentType="text/html; charset=utf-8" language="java"    pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>总管理后台</title>
		<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
		<script type="text/javascript">
		
			function addBigClass(){
				var big_class_weight=jQuery("#big_class_weight").val();
				var big_class_name=jQuery("#big_class_name").val();
				jQuery.post("addBigClass",{big_class_weight:big_class_weight,big_class_name:big_class_name,r:Math.random()},function(json){
					if(json.success==1){
						 alert('操作成功');
						 location.href="admin_base";
					}else{
						 alert('失败了，稍后重试');
					}
				},"json");
			}
			function delBigClass(id){
				if (!confirm("删除大类将级联删除附属小类，确定这么做吗？")){
					return false;
			    }
				jQuery.post("delBigClass",{id:id,r:Math.random()},function(json){
					if(json.success==1){
						 alert('操作成功');
						 location.href="admin_base";
					}else{
						 alert('失败了，稍后重试');
					}
				},"json");
			}
			function updateBigClass(id){
				var bigClassWeight=jQuery("#bigClassWeight"+id).val();
				var bigClassName=jQuery("#bigClassName"+id).val();
				jQuery.post("updateBigClass",{bigClassName:bigClassName,bigClassWeight:bigClassWeight,id:id,r:Math.random()},function(json){
					if(json.success==1){
						 alert('操作成功');
						 location.href="admin_base";
					}else{
						 alert('失败了，稍后重试');
					}
				},"json");
			}
			function updateSmallClass(id){
				var smallClassWeight=jQuery("#smallClassWeight"+id).val();
				var smallClassName=jQuery("#smallClassName"+id).val();
				jQuery.post("updatesmallClass",{smallClassName:smallClassName,smallClassWeight:smallClassWeight,id:id,r:Math.random()},function(json){
					if(json.success==1){
						 alert('操作成功');
						 location.href="admin_base";
					}else{
						 alert('失败了，稍后重试');
					}
				},"json");
			}
			function addsmallClass(){
				var small_class_weight=jQuery("#small_class_weight").val();
				var small_class_name=jQuery("#small_class_name").val();
				var big_class_id=jQuery("#big_class_id").val();
				var isIndexView=jQuery("#isIndexView").val();
				var small_class_content=jQuery("#small_class_content").val();
				jQuery.post("addsmallClass",{small_class_weight:small_class_weight,small_class_name:small_class_name,big_class_id:big_class_id,isIndexView:isIndexView,small_class_content:small_class_content,r:Math.random()},function(json){
					if(json.success==1){
						 alert('操作成功');
						 location.href="admin_base";
					}else{
						 alert('失败了，稍后重试');
					}
				},"json");
			}
			function delsmallClass(id){
				if(confirm("确定要删除么？")){
					jQuery.post("delsmallClass",{id:id,r:Math.random()},function(json){
						if(json.success==1){
							 alert('操作成功');
							 location.href="admin_base";
						}else{
							 alert('失败了，稍后重试');
						}
					},"json");
				}
			}
			function indexView(id){
				jQuery.post("indexView",{id:id,r:Math.random()},function(json){
					if(json.success==1){
						 alert('操作成功');
						 location.href="admin_base";
					}else{
						 alert('失败了，稍后重试');
					}
				},"json");
			}
			
		
		</script>
		<style type="text/css">
			<!--
			body,td,th {
				font-family: 宋体;
				font-size: 12px;
				color: #333333;
			}
			body {
				margin-left: 0px;
				margin-top: 0px;
			}
			-->
		</style>
    </head>
    <body>
        <table width="100%" border="1">
        	<tr>
        		<td  bgcolor="#FF9966">大类ID</td>
        		<td  bgcolor="#FF9966">名称</td>
        		<td bgcolor="#FF9966">权重</td>
        		<td bgcolor="#FF9966">创建时间</td>
        		<td bgcolor="#FF9966">操作</td>
        	</tr>
        	<c:forEach items="${bigClasses}" var="bigClass">
	        	<tr>
	        		<td>${bigClass.id }</td>
	        		<td ><input type="text" value="${bigClass.name }" id="bigClassName${bigClass.id }" /></td>
	        		<td >
	        			<select id="bigClassWeight${bigClass.id }">
	        				<option value="1" <c:if test="${bigClass.weight eq 1 }">selected="selected"</c:if>>1</option>
	        				<option value="2" <c:if test="${bigClass.weight eq 2 }">selected="selected"</c:if>>2</option>
	        				<option value="3" <c:if test="${bigClass.weight eq 3 }">selected="selected"</c:if>>3</option>
	        				<option value="4" <c:if test="${bigClass.weight eq 4 }">selected="selected"</c:if>>4</option>
	        				<option value="5" <c:if test="${bigClass.weight eq 5 }">selected="selected"</c:if>>5</option>
	        			</select>
	        		</td>
	        		<td>${bigClass.createTime }</td>
	        		<td>
	        			<a href="javascript:delBigClass('${bigClass.id }')">删除</a>
	        			<a href="javascript:updateBigClass('${bigClass.id }')">更新</a>
	        		</td>
	        	</tr>
        	</c:forEach>
        	<tr>
        		<td bgcolor="#84FF84">添加大类：</td>
        		<td bgcolor="#84FF84">名称:<input type="text" name="big_class_name" id="big_class_name" /></td>
        		<td bgcolor="#84FF84">权重: 
        			<select name="big_class_weight" id="big_class_weight">
        				<option value="1">1</option>
        				<option value="2">2</option>
        				<option value="3">3</option>
        				<option value="4">4</option>
        				<option value="5">5</option>
        			</select>
        		</td>
        		<td bgcolor="#84FF84"></td>
        		<td bgcolor="#84FF84"><a href="javascript:addBigClass()">点此添加</a></td>
        	</tr>
        </table>
        
        
        
        
        <table width="100%" border="1" style="margin-top: 50px;">
        	<tr>
        		<td  bgcolor="#FF9966">小类ID</td>
        		<td  bgcolor="#FF9966">名称</td>
        		<td bgcolor="#FF9966">权重</td>
        		<td bgcolor="#FF9966">所属大类</td>
        		<td bgcolor="#FF9966">首页显示</td>
        		<td bgcolor="#FF9966">介绍</td>
        		<td bgcolor="#FF9966">创建时间</td>
        		<td bgcolor="#FF9966">操作</td>
        	</tr>
        	<c:forEach items="${smallClasses}" var="smallClass">
	        	<tr>
	        		<td>${smallClass.id }</td>
	        		<td>
	        			<input type="text" value="${smallClass.name }" id="smallClassName${smallClass.id }" />
	        		</td>
	        		<td>
	        			<select id="smallClassWeight${smallClass.id }">
	        				<option value="1" <c:if test="${smallClass.weight eq 1 }">selected="selected"</c:if>>1</option>
	        				<option value="2" <c:if test="${smallClass.weight eq 2 }">selected="selected"</c:if>>2</option>
	        				<option value="3" <c:if test="${smallClass.weight eq 3 }">selected="selected"</c:if>>3</option>
	        				<option value="4" <c:if test="${smallClass.weight eq 4 }">selected="selected"</c:if>>4</option>
	        				<option value="5" <c:if test="${smallClass.weight eq 5 }">selected="selected"</c:if>>5</option>
	        			</select>
	        		</td>
	        		<td>${smallClass.bigClassName }</td>
	        		<td>
	        			<c:if test="${smallClass.isIndexView eq 1}">
	        				是
	        			</c:if>
	        			<c:if test="${smallClass.isIndexView eq 0}">
	        				否
	        			</c:if>
	        		</td>
	        		<td>${smallClass.content }</td>
	        		<td>${smallClass.createTime }</td>
	        		<td>
	        			<a href="javascript:delsmallClass('${smallClass.id }')">删除</a>&nbsp;
	        			<a href="javascript:indexView('${smallClass.id }')">首页显示/取消</a>&nbsp;
	        			<a href="javascript:updateSmallClass('${smallClass.id }')">更新</a>
	        		</td>
	        	</tr>
        	</c:forEach>
        	<tr>
        		<td bgcolor="#84FF84">添加小类：</td>
        		<td bgcolor="#84FF84">名称:<input type="text" name="small_class_name" id="small_class_name" /></td>
        		<td bgcolor="#84FF84">所属大类：
        			<select name="big_class_id" id="big_class_id">
        				<c:forEach items="${bigClasses}" var="bigClass">
        					<option value="${bigClass.id }">${bigClass.name }</option>
        				</c:forEach>
        			</select>
        		</td>
        		<td bgcolor="#84FF84">是否首页显示：
        			<select name="isIndexView" id="isIndexView">
        					<option value="1">是</option>
        					<option value="0">否</option>
        			</select>
        		</td>
        		<td bgcolor="#84FF84">权重: 
        			<select name="small_class_weight" id="small_class_weight">
        				<option value="1">1</option>
        				<option value="2">2</option>
        				<option value="3">3</option>
        				<option value="4">4</option>
        				<option value="5">5</option>
        			</select>
        		</td>
        		<td bgcolor="#84FF84" colspan="2">介绍:
        			<textarea rows="3" cols="50" id="small_class_content"></textarea>
        		</td>
        		<td bgcolor="#84FF84"><a href="javascript:addsmallClass()">点此添加</a></td>
        	</tr>
        </table>
        
        <table width="100%" border="1" style="margin-top: 50px">
        	<tr>
        		<td  bgcolor="#FF9966">添加蛋糕</td>
        	</tr>
        	<tr>
        		<td bgcolor="#84FF84" align="center"><a href="admin_bread">点此添加</a> <a href="viewComments">查看评论</a>  <a href="viewJoinUs">查看加盟</a> </td>
        	</tr>
        </table>
		 
    </body>
</html>
